home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / appkit / nextstd.h < prev    next >
Text File  |  1992-01-30  |  2KB  |  80 lines

  1. /*
  2.     nextstd.h
  3.     Application Kit, Release 2.0
  4.     Copyright (c) 1988, 1989, 1990, NeXT, Inc.  All rights reserved. 
  5. */
  6.  
  7. /* This file has some standard macros useful in any program. */
  8.  
  9. #ifndef NEXTSTD_H
  10. #define NEXTSTD_H
  11.  
  12. #import <math.h>
  13. #import <stdio.h>
  14. #import <libc.h>
  15.  
  16. #ifndef MAX
  17. #define  MAX(A,B)    ((A) > (B) ? (A) : (B))
  18. #endif
  19. #ifndef MIN
  20. #define  MIN(A,B)    ((A) < (B) ? (A) : (B))
  21. #endif
  22. #ifndef ABS
  23. #define  ABS(A)        ((A) < 0 ? (-(A)) : (A))
  24. #endif
  25.  
  26. #define  NX_MALLOC( VAR, TYPE, NUM )                \
  27.    ((VAR) = (TYPE *) malloc((unsigned)(NUM)*sizeof(TYPE))) 
  28.  
  29. #define  NX_REALLOC( VAR, TYPE, NUM )                \
  30.    ((VAR) = (TYPE *) realloc((VAR), (unsigned)(NUM)*sizeof(TYPE)))
  31.  
  32. #define  NX_FREE( PTR )    free((PTR))
  33.  
  34. #define  NX_ZONEMALLOC( Z, VAR, TYPE, NUM )                \
  35.    ((VAR) = (TYPE *) NXZoneMalloc((Z), (unsigned)(NUM)*sizeof(TYPE))) 
  36.  
  37. #define  NX_ZONEREALLOC( Z, VAR, TYPE, NUM )                \
  38.    ((VAR) = (TYPE *) NXZoneRealloc ((Z), (char *)(VAR),         \
  39.        (unsigned)(NUM)*sizeof(TYPE)))
  40.  
  41. #ifndef NBITSCHAR
  42. #define NBITSCHAR    8
  43. #endif NBITSCHAR
  44.  
  45. #ifndef NBITSINT
  46. #define NBITSINT    (sizeof(int)*NBITSCHAR)
  47. #endif NBITSINT
  48.  
  49. #ifndef TRUE
  50. #define TRUE        1
  51. #endif TRUE
  52. #ifndef FALSE
  53. #define FALSE        0
  54. #endif FALSE
  55.  
  56. /*
  57.  * compile with -DNX_BLOCKASSERTS to turn off asserts in your code
  58.  */
  59.  
  60. #ifndef NX_BLOCKASSERTS
  61. extern void NXLogError(const char *format, ...);
  62. #define NX_ASSERT(exp,str)        {if(!(exp)) NXLogError("Assertion failed: %s\n", str);}
  63. #else NX_BLOCKASSERTS
  64. #define NX_ASSERT(exp,str) {}
  65. #endif NX_BLOCKASSERTS
  66.  
  67. /*
  68.  * Used to insert messages in showps output.  If you use this macro, you can
  69.  * compile with -DNX_BLOCKPSDEBUG to turn it off.  Note that it only writes
  70.  * its messages when showps is on.
  71.  */
  72.  
  73. #ifndef NX_BLOCKPSDEBUG
  74. #define NX_PSDEBUG()        {if ((DPSGetCurrentContext())->chainChild && (DPSGetCurrentContext())->chainChild->programEncoding == dps_ascii) DPSPrintf( DPSGetCurrentContext(),"\n%% *** Debug *** Object:%d Class:%s Method:%s\n", ((int)self), ((char *)[self name]), SELNAME(_cmd));}
  75. #else NX_BLOCKPSDEBUG
  76. #define NX_PSDEBUG() {}
  77. #endif NX_BLOCKPSDEBUG
  78.  
  79. #endif
  80.